﻿using System;
using GigaSite.Domain.Entities;
using Newtonsoft.Json;

namespace GigaSite.Web.Areas.ControlPanel.Models
{
    /// <summary>
    /// Модель новости
    /// </summary>
    public class NewsArticleModel
    {
        /// <summary>
        /// Идентификатор новости
        /// </summary>
        [JsonProperty("id")]
        public long Id { get; set; }

        /// <summary>
        /// Ключевые слова по новости
        /// </summary>
        [JsonProperty("tags")]
        public string Tags { get; set; }

        /// <summary>
        /// Заголовок
        /// </summary>
        [JsonProperty("title")]
        public string Title { get; set; }

        /// <summary>
        /// Краткое содержание, анонс
        /// </summary>
        [JsonProperty("shortContent")]
        public string ShortContent { get; set; }

        /// <summary>
        /// Полное содержание
        /// </summary>
        [JsonProperty("fullContent")]
        public string FullContent { get; set; }

        /// <summary>
        /// Количество просмотров
        /// </summary>
        [JsonProperty("views")]
        public int Views { get; set; }

        /// <summary>
        /// Новость опубликована
        /// </summary>
        [JsonProperty("published")]
        public bool Published { get; set; }

        /// <summary>
        /// Новость должна быть опубликована позднее
        /// </summary>
        [JsonProperty("delayPublication")]
        public bool DelayPublication { get; set; }

        /// <summary>
        /// Дата отложенной публикации новости
        /// </summary>
        [JsonProperty("delayPublicationDate")]
        public DateTime? DelayPublicationDate { get; set; }

        /// <summary>
        /// Отключить комментирование новости
        /// </summary>
        [JsonProperty("disableCommenting")]
        public bool DisableCommenting { get; set; }

        /// <summary>
        /// Дата создания новости
        /// </summary>
        [JsonProperty("dateCreated")]
        public DateTime? DateCreated { get; set; }
        
        /// <summary>
        /// Дата последнего изменения новости
        /// </summary>
        [JsonProperty("dateModified")]
        public DateTime? DateModified { get; set; }

        /// <summary>
        /// Стандартный конструктор
        /// </summary>
        public NewsArticleModel()
        {
        }

        /// <summary>
        /// Коснтруктор на основе доменной модели
        /// </summary>
        /// <param name="article">Доменная модель</param>
        public NewsArticleModel(NewsArticle article)
        {
            Id = article.Id;
            Tags = article.Tags;
            Title = article.Title;
            ShortContent = article.ShortContent;
            FullContent = article.FullContent;
            Views = article.Views;
            Published = article.Published;
            DelayPublication = article.DelayPublished;
            DelayPublicationDate = article.DelayPublicationDate;
            DisableCommenting = article.DisableCommenting;
            DateCreated = article.DateCreated;
            DateModified = article.DateModified;
        }
    }
}